### Replication File for "Bureaucracy and Policymaking: Evidence from a Choice-Based Conjoint Analysis" 

library(ggplot2)
library(tidyverse)
library(stargazer)
library(dotwhisker)

load("SurveyMin2.Rda")

bp<-sm

bp = subset(bp, select = c(id, QD_Transparencia, QD_Esforço, QD_Evidencia, QD_Articulação,QD_Geral, 
                           QD_Transparencia_SIndif, QD_Esforço_SIndif, QD_Evidencia_SIndif,QD_Articulação_SIndif, QD_Geral_SIndif, 
                           QD_Transparencia2, QD_Esforço2, QD_Evidencia2, QD_Articulação2, QD_Geral2, 
                           QD_TransparenciaIndif, QD_EsforçoIndif, QD_EvidenciaIndif, QD_ArticulaçãoIndif, QD_GeralIndif,
                           QA1_2, QA6, QA7, QE1) )


save(bp, file="Bureaucracy&Policymaking.Rda")


load("Bureaucracy&Policymaking.Rda")

### Table 2: Main results (without indifference)

m1<-lm(QD_Transparencia_SIndif~  EXP5_Vinculo + Exp5_Tempo5Anos + Exp5_Tempo10Anos +EXP5_Genero, data=bp)
m2<-lm(QD_Esforço_SIndif~  EXP5_Vinculo + Exp5_Tempo5Anos + Exp5_Tempo10Anos +EXP5_Genero, data=bp)
m3<-lm(QD_Evidencia_SIndif~  EXP5_Vinculo + Exp5_Tempo5Anos + Exp5_Tempo10Anos +EXP5_Genero, data=bp)
m4<-lm(QD_Articulação_SIndif ~  EXP5_Vinculo + Exp5_Tempo5Anos + Exp5_Tempo10Anos +EXP5_Genero, data=bp)
m5<-lm(QD_Geral_SIndif ~  EXP5_Vinculo + Exp5_Tempo5Anos + Exp5_Tempo10Anos +EXP5_Genero, data=bp)

stargazer(m1,m3,m2,m4,m5, title="RES1", type="html",out="Res_WithoutIndifference.doc")

#

m1_df <- broom::tidy(m1)  %>% mutate(model = "Transparency") %>% relabel_predictors(c(
  EXP5_Vinculoservidor = "Appointee: Career Bureaucrat",
  Exp5_Tempo5Anos = "Experience: 5 Years",
  Exp5_Tempo10Anos = "Experience: 10 Years",
  EXP5_Generofeminino = "Gender: Female"
))

m2_df <- broom::tidy(m2)  %>% mutate(model = "Effort") %>% relabel_predictors(c(
  EXP5_Vinculoservidor = "Appointee: Career Bureaucrat",
  Exp5_Tempo5Anos = "Experience: 5 Years",
  Exp5_Tempo10Anos = "Experience: 10 Years",
  EXP5_Generofeminino = "Gender: Female"
))

m3_df <- broom::tidy(m3)  %>% mutate(model = "Evidence") %>% relabel_predictors(c(
  EXP5_Vinculoservidor = "Appointee: Career Bureaucrat",
  Exp5_Tempo5Anos = "Experience: 5 Years",
  Exp5_Tempo10Anos = "Experience: 10 Years",
  EXP5_Generofeminino = "Gender: Female"
))


m4_df <- broom::tidy(m4)  %>% mutate(model = "Political") %>% relabel_predictors(c(
  EXP5_Vinculoservidor = "Appointee: Career Bureaucrat",
  Exp5_Tempo5Anos = "Experience: 5 Years",
  Exp5_Tempo10Anos = "Experience: 10 Years",
  EXP5_Generofeminino = "Gender: Female"
))

m5_df <- broom::tidy(m5)  %>% mutate(model = "General") %>% relabel_predictors(c(
  EXP5_Vinculoservidor = "Appointee: Career Bureaucrat",
  Exp5_Tempo5Anos = "Experience: 5 Years",
  Exp5_Tempo10Anos = "Experience: 10 Years",
  EXP5_Generofeminino = "Gender: Female"
))


dwplot(m1_df, dot_args = list(aes(shape = model)),
       whisker_args = list(aes(linetype = model)))+
  geom_vline(xintercept = 0, colour = "red", linetype = 2) + 
  theme_bw() + xlab("Coefficient Estimate") +
  theme(legend.position = "none") +
  scale_colour_grey(start = .1, end = .1) +
  scale_shape_discrete() +
  guides(shape = guide_legend(), colour = guide_legend()) +
  theme(axis.text=element_text(size=14)) + 
  ggtitle("Best perform the role of  transparent resource administration")+
  theme(plot.title = element_text(size = 14, face = "bold"))

#
dwplot(m2_df, dot_args = list(aes(shape = model)),
       whisker_args = list(aes(linetype = model)))+
  geom_vline(xintercept = 0, colour = "red", linetype = 2) + 
  theme_bw() + xlab("Coefficient Estimate") +
  theme(legend.position = "none") +
  scale_colour_grey(start = .1, end = .1) +
  scale_shape_discrete() +
  guides(shape = guide_legend(), colour = guide_legend()) +
  theme(axis.text=element_text(size=14)) + 
  ggtitle("Most easily motivated to work overtime towards the completion of the project")+
  theme(plot.title = element_text(size = 14, face = "bold"))


#
dwplot(m3_df, dot_args = list(aes(shape = model)),
       whisker_args = list(aes(linetype = model)))+
  geom_vline(xintercept = 0, colour = "red", linetype = 2) + 
  theme_bw() + xlab("Coefficient Estimate") +
  theme(legend.position = "none") +
  scale_colour_grey(start = .1, end = .1) +
  scale_shape_discrete() +
  guides(shape = guide_legend(), colour = guide_legend()) +
  theme(axis.text=element_text(size=14)) + 
  ggtitle("Best perform the role of mobilizing data and information for decision making")+
  theme(plot.title = element_text(size = 14, face = "bold"))


#
dwplot(m4_df, dot_args = list(aes(shape = model)),
       whisker_args = list(aes(linetype = model)))+
  geom_vline(xintercept = 0, colour = "red", linetype = 2) + 
  theme_bw() + xlab("Coefficient Estimate") +
  theme(legend.position = "none") +
  scale_colour_grey(start = .1, end = .1) +
  scale_shape_discrete() +
  guides(shape = guide_legend(), colour = guide_legend()) +
  theme(axis.text=element_text(size=14)) + 
  ggtitle("Best perform the role of political coordination")+
  theme(plot.title = element_text(size = 14, face = "bold"))

#
dwplot(m5_df, dot_args = list(aes(shape = model)),
       whisker_args = list(aes(linetype = model)))+
  geom_vline(xintercept = 0, colour = "red", linetype = 2) + 
  theme_bw() + xlab("Coefficient Estimate") +
  theme(legend.position = "none") +
  scale_colour_grey(start = .1, end = .1) +
  scale_shape_discrete() +
  guides(shape = guide_legend(), colour = guide_legend()) +
  theme(axis.text=element_text(size=14)) + 
  ggtitle("Considering all the dimensions, which candidate was selected")+
  theme(plot.title = element_text(size = 14, face = "bold"))



## Supplementary Materials - Table A3: Results with Indifference

m1<-lm(QD_Transparencia2~  EXP5_Vinculo + Exp5_Tempo5Anos + Exp5_Tempo10Anos +EXP5_Genero, data=bp)
m2<-lm(QD_Esforço2~  EXP5_Vinculo + Exp5_Tempo5Anos + Exp5_Tempo10Anos +EXP5_Genero, data=bp)
m3<-lm(QD_Evidencia2~  EXP5_Vinculo + Exp5_Tempo5Anos + Exp5_Tempo10Anos +EXP5_Genero, data=bp)
m4<-lm(QD_Articulação2 ~  EXP5_Vinculo + Exp5_Tempo5Anos + Exp5_Tempo10Anos +EXP5_Genero, data=bp)
m5<-lm(QD_Geral2 ~  EXP5_Vinculo + Exp5_Tempo5Anos + Exp5_Tempo10Anos +EXP5_Genero, data=bp)

stargazer(m1,m3,m2,m4,m5, title="RES1", type="html",out="ComIndiferença2.doc")


summary(m5)


### Supplementary Materials - Table A4: Indifference as Choice

m1<-lm(QD_TransparenciaIndif~  EXP5_Vinculo + Exp5_Tempo5Anos + Exp5_Tempo10Anos +EXP5_Genero, data=bp)
m2<-lm(QD_EsforçoIndif~  EXP5_Vinculo + Exp5_Tempo5Anos + Exp5_Tempo10Anos +EXP5_Genero, data=bp)
m3<-lm(QD_EvidenciaIndif~  EXP5_Vinculo + Exp5_Tempo5Anos + Exp5_Tempo10Anos +EXP5_Genero, data=bp)
m4<-lm(QD_ArticulaçãoIndif ~  EXP5_Vinculo + Exp5_Tempo5Anos + Exp5_Tempo10Anos +EXP5_Genero, data=bp)
m5<-lm(QD_GeralIndif ~  EXP5_Vinculo + Exp5_Tempo5Anos + Exp5_Tempo10Anos +EXP5_Genero, data=bp)

stargazer(m1,m2,m3,m4,m5, title="RES1", type="html",out="Indiferença.doc")


###

# Supplementary Materials - Table A5: Career bureaucrat versus political appointee 

smp<-bp[ which(bp$QA1_2=="1"), ]
smt<-bp[ which(bp$QA1_2=="0"), ]


#Career bureaucrats only

m1<-lm(QD_Transparencia_SIndif~  EXP5_Vinculo + Exp5_Tempo5Anos + Exp5_Tempo10Anos +EXP5_Genero, data=smt)
m2<-lm(QD_Esforço_SIndif~  EXP5_Vinculo + Exp5_Tempo5Anos + Exp5_Tempo10Anos +EXP5_Genero, data=smt)
m3<-lm(QD_Evidencia_SIndif~  EXP5_Vinculo + Exp5_Tempo5Anos + Exp5_Tempo10Anos +EXP5_Genero, data=smt)
m4<-lm(QD_Articulação_SIndif ~  EXP5_Vinculo + Exp5_Tempo5Anos + Exp5_Tempo10Anos +EXP5_Genero, data=smt)
m5<-lm(QD_Geral_SIndif ~  EXP5_Vinculo + Exp5_Tempo5Anos + Exp5_Tempo10Anos +EXP5_Genero, data=smt)

stargazer(m1,m3,m2,m4,m5, title="RES1", type="html",out="SemIndiferencaTecnicos.doc")



#Political appointees only

m1<-lm(QD_Transparencia_SIndif~  EXP5_Vinculo + Exp5_Tempo5Anos + Exp5_Tempo10Anos +EXP5_Genero, data=smp)
m2<-lm(QD_Esforço_SIndif~  EXP5_Vinculo + Exp5_Tempo5Anos + Exp5_Tempo10Anos +EXP5_Genero, data=smp)
m3<-lm(QD_Evidencia_SIndif~  EXP5_Vinculo + Exp5_Tempo5Anos + Exp5_Tempo10Anos +EXP5_Genero, data=smp)
m4<-lm(QD_Articulação_SIndif ~  EXP5_Vinculo + Exp5_Tempo5Anos + Exp5_Tempo10Anos +EXP5_Genero, data=smp)
m5<-lm(QD_Geral_SIndif ~  EXP5_Vinculo + Exp5_Tempo5Anos + Exp5_Tempo10Anos +EXP5_Genero, data=smp)

stargazer(m1,m3,m2,m4,m5, title="RES1", type="html",out="SemIndiferencaPoliticos.doc")
